@contentauth/c2pa-web 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,57 @@
1
1
  # c2pa-web
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ The SDK for interacting with [C2PA metadata](https://c2pa.org/) on the web.
4
4
 
5
- ## Building
5
+ As a guiding philosophy, `c2pa-web` attempts to adhere closely to the API paradigms established by [`c2pa-rs`](https://github.com/contentauth/c2pa-rs).
6
6
 
7
- Run `nx build c2pa-web` to build the library.
7
+ ## Installation
8
8
 
9
- ## Running unit tests
9
+ ```sh
10
+ npm install @contentauth/c2pa-web
11
+ ```
10
12
 
11
- Run `nx test c2pa-web` to execute the unit tests via [Vitest](https://vitest.dev/).
13
+ ## Quickstart
14
+
15
+ ```typescript
16
+ import { createC2pa } from "@contentauth/c2pa-web";
17
+
18
+ // Using vite's ?url query parameter - use a solution appropriate to your tooling.
19
+ // This resolves to a WASM binary that must be available for the library to fetch at runtime.
20
+ import wasmSrc from "@contentauth/c2pa-web/resources/c2pa.wasm?url";
21
+
22
+ const response = await fetch("https://spec.c2pa.org/public-testfiles/image/jpeg/adobe-20220124-C.jpg");
23
+ const blob = await response.blob();
24
+
25
+ const reader = await c2pa.reader.fromBlob(blob.type, blob);
26
+
27
+ const manifestStore = await reader.manifestStore();
28
+
29
+ console.log(manifestStore);
30
+ ```
31
+
32
+ ## Development
33
+
34
+ ### Prerequsities
35
+
36
+ Ensure the repo-wide prerequisites [NX](https://nx.dev/getting-started/intro) and [pnpm](https://pnpm.io/) are installed.
37
+
38
+ [`c2pa-wasm`'s prerequisites](https://github.com/contentauth/c2pa-js-v2/tree/main/packages/c2pa-wasm) must also be installed.
39
+
40
+ ### Building
41
+
42
+ To build the library:
43
+ ```sh
44
+ nx build c2pa-web
45
+ ```
46
+
47
+ ### Testing
48
+
49
+ This library relies on [Vitest](https://vitest.dev/) to run its tests in a headless browser. Before the tests can be run, the test browser binaries must be installed:
50
+ ```sh
51
+ pnpx playwright install
52
+ ```
53
+
54
+ To run the tests:
55
+ ```
56
+ nx test c2pa-web
57
+ ```
package/dist/index.d.ts CHANGED
@@ -7,7 +7,8 @@
7
7
  * it.
8
8
  */
9
9
  export * from './lib/c2pa.js';
10
+ export type { Reader, ReaderFactory } from './lib/reader.js';
10
11
  export { isSupportedReaderFormat, READER_SUPPORTED_FORMATS, } from './lib/supportedFormats.js';
11
- export { type Settings } from './lib/settings.js';
12
+ export type { Settings, VerifySettings, TrustSettings } from './lib/settings.js';
12
13
  export type * from '@contentauth/c2pa-types';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,eAAe,CAAC;AAE9B,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,mBAAmB,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,eAAe,CAAC;AAE9B,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGjF,mBAAmB,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const l = '(function(){"use strict";let o;const j=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&j.decode();let y=null;function T(){return(y===null||y.byteLength===0)&&(y=new Uint8Array(o.memory.buffer)),y}function a(t,e){return t=t>>>0,j.decode(T().subarray(t,t+e))}function p(t){const e=o.__externref_table_alloc();return o.__wbindgen_export_2.set(e,t),e}function u(t,e){try{return t.apply(this,e)}catch(n){const r=p(n);o.__wbindgen_exn_store(r)}}let f=0;const M=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},F=typeof M.encodeInto=="function"?function(t,e){return M.encodeInto(t,e)}:function(t,e){const n=M.encode(t);return e.set(n),{read:t.length,written:n.length}};function g(t,e,n){if(n===void 0){const s=M.encode(t),d=e(s.length,1)>>>0;return T().subarray(d,d+s.length).set(s),f=s.length,d}let r=t.length,_=e(r,1)>>>0;const c=T();let i=0;for(;i<r;i++){const s=t.charCodeAt(i);if(s>127)break;c[_+i]=s}if(i!==r){i!==0&&(t=t.slice(i)),_=n(_,r,r=i+t.length*3,1)>>>0;const s=T().subarray(_+i,_+r),d=F(t,s);i+=d.written,_=n(_,r,i,1)>>>0}return f=i,_}let l=null;function w(){return(l===null||l.buffer.detached===!0||l.buffer.detached===void 0&&l.buffer!==o.memory.buffer)&&(l=new DataView(o.memory.buffer)),l}function h(t){return t==null}const A=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>{o.__wbindgen_export_6.get(t.dtor)(t.a,t.b)});function O(t,e,n,r){const _={a:t,b:e,cnt:1,dtor:n},c=(...i)=>{_.cnt++;const s=_.a;_.a=0;try{return r(s,_.b,...i)}finally{--_.cnt===0?(o.__wbindgen_export_6.get(_.dtor)(s,_.b),A.unregister(_)):_.a=s}};return c.original=_,A.register(c,_,_),c}function S(t){const e=typeof t;if(e=="number"||e=="boolean"||t==null)return`${t}`;if(e=="string")return`"${t}"`;if(e=="symbol"){const _=t.description;return _==null?"Symbol":`Symbol(${_})`}if(e=="function"){const _=t.name;return typeof _=="string"&&_.length>0?`Function(${_})`:"Function"}if(Array.isArray(t)){const _=t.length;let c="[";_>0&&(c+=S(t[0]));for(let i=1;i<_;i++)c+=", "+S(t[i]);return c+="]",c}const n=/\\[object ([^\\]]+)\\]/.exec(toString.call(t));let r;if(n&&n.length>1)r=n[1];else return toString.call(t);if(r=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:r}function m(t){const e=o.__wbindgen_export_2.get(t);return o.__externref_table_dealloc(t),e}function I(t){const e=g(t,o.__wbindgen_malloc,o.__wbindgen_realloc),n=f,r=o.loadSettings(e,n);if(r[1])throw m(r[0])}function k(t,e){o._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf8e9222f46d15a02(t,e)}function R(t,e,n){o.closure1461_externref_shim(t,e,n)}function L(t,e,n,r){o.closure2453_externref_shim(t,e,n,r)}const W=["omit","same-origin","include"],v=["same-origin","no-cors","cors","navigate"],B=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>o.__wbg_wasmreader_free(t>>>0,1));class x{static __wrap(e){e=e>>>0;const n=Object.create(x.prototype);return n.__wbg_ptr=e,B.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,B.unregister(this),e}free(){const e=this.__destroy_into_raw();o.__wbg_wasmreader_free(e,0)}static fromBlob(e,n){const r=g(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=f;return o.wasmreader_fromBlob(r,_,n)}static fromBlobFragment(e,n,r){const _=g(e,o.__wbindgen_malloc,o.__wbindgen_realloc),c=f;return o.wasmreader_fromBlobFragment(_,c,n,r)}activeLabel(){const e=o.wasmreader_activeLabel(this.__wbg_ptr);let n;return e[0]!==0&&(n=a(e[0],e[1]).slice(),o.__wbindgen_free(e[0],e[1]*1,1)),n}manifestStore(){const e=o.wasmreader_manifestStore(this.__wbg_ptr);if(e[2])throw m(e[1]);return m(e[0])}activeManifest(){const e=o.wasmreader_activeManifest(this.__wbg_ptr);if(e[2])throw m(e[1]);return m(e[0])}json(){let e,n;try{const r=o.wasmreader_json(this.__wbg_ptr);return e=r[0],n=r[1],a(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}resourceToBuffer(e){const n=g(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=f,_=o.wasmreader_resourceToBuffer(this.__wbg_ptr,n,r);if(_[2])throw m(_[1]);return m(_[0])}}function D(){const t={};return t.wbg={},t.wbg.__wbg_abort_410ec47a64ac6117=function(e,n){e.abort(n)},t.wbg.__wbg_abort_775ef1d17fc65868=function(e){e.abort()},t.wbg.__wbg_append_8c7dd8d641a5f01b=function(){return u(function(e,n,r,_,c){e.append(a(n,r),a(_,c))},arguments)},t.wbg.__wbg_arrayBuffer_d1b44c4390db422f=function(){return u(function(e){return e.arrayBuffer()},arguments)},t.wbg.__wbg_buffer_09165b52af8c5237=function(e){return e.buffer},t.wbg.__wbg_buffer_609cc3eee51ed158=function(e){return e.buffer},t.wbg.__wbg_byteLength_e674b853d9c77e1d=function(e){return e.byteLength},t.wbg.__wbg_call_672a4d21634d4a24=function(){return u(function(e,n){return e.call(n)},arguments)},t.wbg.__wbg_call_7cccdd69e0791ae2=function(){return u(function(e,n,r){return e.call(n,r)},arguments)},t.wbg.__wbg_clearTimeout_0b53d391c1b94dda=function(e){return clearTimeout(e)},t.wbg.__wbg_done_769e5ede4b31c67b=function(e){return e.done},t.wbg.__wbg_error_7534b8e9a36f1ab4=function(e,n){let r,_;try{r=e,_=n,console.error(a(e,n))}finally{o.__wbindgen_free(r,_,1)}},t.wbg.__wbg_fetch_11bff8299d0ecd2b=function(e){return fetch(e)},t.wbg.__wbg_fetch_509096533071c657=function(e,n){return e.fetch(n)},t.wbg.__wbg_from_2a5d3e218e67aa85=function(e){return Array.from(e)},t.wbg.__wbg_getTime_46267b1c24877e30=function(e){return e.getTime()},t.wbg.__wbg_get_67b2ba62fc30de12=function(){return u(function(e,n){return Reflect.get(e,n)},arguments)},t.wbg.__wbg_has_a5ea9117f258a0ec=function(){return u(function(e,n){return Reflect.has(e,n)},arguments)},t.wbg.__wbg_headers_9cb51cfd2ac780a4=function(e){return e.headers},t.wbg.__wbg_instanceof_Response_f2cc20d9f7dfd644=function(e){let n;try{n=e instanceof Response}catch{n=!1}return n},t.wbg.__wbg_iterator_9a24c88df860dc65=function(){return Symbol.iterator},t.wbg.__wbg_length_a446193dc22c12f8=function(e){return e.length},t.wbg.__wbg_new0_f788a2397c7ca929=function(){return new Date},t.wbg.__wbg_new_018dcc2d6c8c2f6a=function(){return u(function(){return new Headers},arguments)},t.wbg.__wbg_new_16004015965f986e=function(){return u(function(){return new FileReaderSync},arguments)},t.wbg.__wbg_new_23a2665fac83c611=function(e,n){try{var r={a:e,b:n},_=(i,s)=>{const d=r.a;r.a=0;try{return L(d,r.b,i,s)}finally{r.a=d}};return new Promise(_)}finally{r.a=r.b=0}},t.wbg.__wbg_new_405e22f390576ce2=function(){return new Object},t.wbg.__wbg_new_5e0be73521bc8c17=function(){return new Map},t.wbg.__wbg_new_78feb108b6472713=function(){return new Array},t.wbg.__wbg_new_8a6f238a6ece86ea=function(){return new Error},t.wbg.__wbg_new_a12002a7f91c75be=function(e){return new Uint8Array(e)},t.wbg.__wbg_new_c68d7209be747379=function(e,n){return new Error(a(e,n))},t.wbg.__wbg_new_e25e5aab09ff45db=function(){return u(function(){return new AbortController},arguments)},t.wbg.__wbg_newnoargs_105ed471475aaf50=function(e,n){return new Function(a(e,n))},t.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a=function(e,n,r){return new Uint8Array(e,n>>>0,r>>>0)},t.wbg.__wbg_newwithlength_a381634e90c276d4=function(e){return new Uint8Array(e>>>0)},t.wbg.__wbg_newwithstrandinit_06c535e0a867c635=function(){return u(function(e,n,r){return new Request(a(e,n),r)},arguments)},t.wbg.__wbg_next_25feadfc0913fea9=function(e){return e.next},t.wbg.__wbg_next_6574e1a8a62d1055=function(){return u(function(e){return e.next()},arguments)},t.wbg.__wbg_now_807e54c39636c349=function(){return Date.now()},t.wbg.__wbg_queueMicrotask_97d92b4fcc8a61c5=function(e){queueMicrotask(e)},t.wbg.__wbg_queueMicrotask_d3219def82552485=function(e){return e.queueMicrotask},t.wbg.__wbg_readAsArrayBuffer_560aeb9fce36c5c8=function(){return u(function(e,n){return e.readAsArrayBuffer(n)},arguments)},t.wbg.__wbg_resolve_4851785c9c5f573d=function(e){return Promise.resolve(e)},t.wbg.__wbg_setTimeout_73ce8df12de4f2f2=function(e,n){return setTimeout(e,n)},t.wbg.__wbg_set_37837023f3d740e8=function(e,n,r){e[n>>>0]=r},t.wbg.__wbg_set_3f1d0b984ed272ed=function(e,n,r){e[n]=r},t.wbg.__wbg_set_65595bdd868b3009=function(e,n,r){e.set(n,r>>>0)},t.wbg.__wbg_set_8fc6bf8a5b1071d1=function(e,n,r){return e.set(n,r)},t.wbg.__wbg_setbody_5923b78a95eedf29=function(e,n){e.body=n},t.wbg.__wbg_setcredentials_c3a22f1cd105a2c6=function(e,n){e.credentials=W[n]},t.wbg.__wbg_setheaders_834c0bdb6a8949ad=function(e,n){e.headers=n},t.wbg.__wbg_setmethod_3c5280fe5d890842=function(e,n,r){e.method=a(n,r)},t.wbg.__wbg_setmode_5dc300b865044b65=function(e,n){e.mode=v[n]},t.wbg.__wbg_setsignal_75b21ef3a81de905=function(e,n){e.signal=n},t.wbg.__wbg_signal_aaf9ad74119f20a4=function(e){return e.signal},t.wbg.__wbg_size_3808d41635a9c259=function(e){return e.size},t.wbg.__wbg_slice_bd4c84b64bdfe01f=function(){return u(function(e,n,r){return e.slice(n,r)},arguments)},t.wbg.__wbg_stack_0ed75d68575b0f3c=function(e,n){const r=n.stack,_=g(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=f;w().setInt32(e+4,c,!0),w().setInt32(e+0,_,!0)},t.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07=function(){const e=typeof global>"u"?null:global;return h(e)?0:p(e)},t.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0=function(){const e=typeof globalThis>"u"?null:globalThis;return h(e)?0:p(e)},t.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819=function(){const e=typeof self>"u"?null:self;return h(e)?0:p(e)},t.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40=function(){const e=typeof window>"u"?null:window;return h(e)?0:p(e)},t.wbg.__wbg_status_f6360336ca686bf0=function(e){return e.status},t.wbg.__wbg_stringify_f7ed6987935b4a24=function(){return u(function(e){return JSON.stringify(e)},arguments)},t.wbg.__wbg_then_44b73946d2fb3e7d=function(e,n){return e.then(n)},t.wbg.__wbg_then_48b406749878a531=function(e,n,r){return e.then(n,r)},t.wbg.__wbg_url_ae10c34ca209681d=function(e,n){const r=n.url,_=g(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=f;w().setInt32(e+4,c,!0),w().setInt32(e+0,_,!0)},t.wbg.__wbg_value_cd1ffa7b1ab794f1=function(e){return e.value},t.wbg.__wbg_wasmreader_new=function(e){return x.__wrap(e)},t.wbg.__wbindgen_as_number=function(e){return+e},t.wbg.__wbindgen_bigint_from_i64=function(e){return e},t.wbg.__wbindgen_bigint_from_u64=function(e){return BigInt.asUintN(64,e)},t.wbg.__wbindgen_cb_drop=function(e){const n=e.original;return n.cnt--==1?(n.a=0,!0):!1},t.wbg.__wbindgen_closure_wrapper10863=function(e,n,r){return O(e,n,1444,k)},t.wbg.__wbindgen_closure_wrapper10914=function(e,n,r){return O(e,n,1462,R)},t.wbg.__wbindgen_debug_string=function(e,n){const r=S(n),_=g(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=f;w().setInt32(e+4,c,!0),w().setInt32(e+0,_,!0)},t.wbg.__wbindgen_error_new=function(e,n){return new Error(a(e,n))},t.wbg.__wbindgen_init_externref_table=function(){const e=o.__wbindgen_export_2,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,!0),e.set(n+3,!1)},t.wbg.__wbindgen_is_function=function(e){return typeof e=="function"},t.wbg.__wbindgen_is_object=function(e){const n=e;return typeof n=="object"&&n!==null},t.wbg.__wbindgen_is_string=function(e){return typeof e=="string"},t.wbg.__wbindgen_is_undefined=function(e){return e===void 0},t.wbg.__wbindgen_memory=function(){return o.memory},t.wbg.__wbindgen_number_new=function(e){return e},t.wbg.__wbindgen_string_get=function(e,n){const r=n,_=typeof r=="string"?r:void 0;var c=h(_)?0:g(_,o.__wbindgen_malloc,o.__wbindgen_realloc),i=f;w().setInt32(e+4,i,!0),w().setInt32(e+0,c,!0)},t.wbg.__wbindgen_string_new=function(e,n){return a(e,n)},t.wbg.__wbindgen_throw=function(e,n){throw new Error(a(e,n))},t}function z(t,e){return o=t.exports,l=null,y=null,o.__wbindgen_start(),o}function U(t){if(o!==void 0)return o;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=D();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));const n=new WebAssembly.Instance(t,e);return z(n)}function E(t,e){const n={type:"success",...t!==void 0?{payload:t}:{}};postMessage(n,e??[])}function q(t){postMessage({type:"error",error:t})}function C(t){onmessage=async e=>{try{const{args:n,method:r}=e.data,_=await t[r](...n);(_==null?void 0:_.data)!==void 0?E(_.data,_.transfer):E()}catch(n){q(n)}}}function N(){let t=0;const e=new Map;return{add(n){const r=t++;return e.set(r,n),r},get(n){const r=e.get(n);if(!r)throw new Error("Attempted to use an object that has been freed");return r},remove(n){return e.delete(n)}}}const b=N();C({async initWorker(t,e){U(t),e&&I(e)},async reader_fromBlob(t,e){const n=await x.fromBlob(t,e);return{data:b.add(n)}},async reader_fromBlobFragment(t,e,n){const r=await x.fromBlobFragment(t,e,n);return{data:b.add(r)}},reader_activeLabel(t){return{data:b.get(t).activeLabel()??null}},reader_manifestStore(t){return{data:b.get(t).manifestStore()}},reader_activeManifest(t){return{data:b.get(t).activeManifest()}},reader_json(t){return{data:b.get(t).json()}},reader_resourceToBuffer(t,e){const r=b.get(t).resourceToBuffer(e);return{data:r,transfer:[r]}},reader_free(t){b.get(t).free(),b.remove(t)}})})();\n', f = typeof self < "u" && self.Blob && new Blob([l], { type: "text/javascript;charset=utf-8" });
1
+ const l = '(function(){"use strict";let o,y=null;function p(){return(y===null||y.byteLength===0)&&(y=new Uint8Array(o.memory.buffer)),y}let A=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&A.decode();const I=2146435072;let S=0;function D(t,e){return S+=e,S>=I&&(A=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}},A.decode(),S=e),A.decode(p().subarray(t,t+e))}function b(t,e){return t=t>>>0,D(t,e)}function h(t){const e=o.__externref_table_alloc();return o.__wbindgen_export_2.set(e,t),e}function u(t,e){try{return t.apply(this,e)}catch(n){const r=h(n);o.__wbindgen_exn_store(r)}}function k(t,e){return t=t>>>0,p().subarray(t/1,t/1+e)}let a=0;const M=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},R=typeof M.encodeInto=="function"?function(t,e){return M.encodeInto(t,e)}:function(t,e){const n=M.encode(t);return e.set(n),{read:t.length,written:n.length}};function g(t,e,n){if(n===void 0){const s=M.encode(t),w=e(s.length,1)>>>0;return p().subarray(w,w+s.length).set(s),a=s.length,w}let r=t.length,_=e(r,1)>>>0;const c=p();let i=0;for(;i<r;i++){const s=t.charCodeAt(i);if(s>127)break;c[_+i]=s}if(i!==r){i!==0&&(t=t.slice(i)),_=n(_,r,r=i+t.length*3,1)>>>0;const s=p().subarray(_+i,_+r),w=R(t,s);i+=w.written,_=n(_,r,i,1)>>>0}return a=i,_}let l=null;function d(){return(l===null||l.buffer.detached===!0||l.buffer.detached===void 0&&l.buffer!==o.memory.buffer)&&(l=new DataView(o.memory.buffer)),l}function x(t){return t==null}const j=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>{o.__wbindgen_export_6.get(t.dtor)(t.a,t.b)});function B(t,e,n,r){const _={a:t,b:e,cnt:1,dtor:n},c=(...i)=>{_.cnt++;const s=_.a;_.a=0;try{return r(s,_.b,...i)}finally{--_.cnt===0?(o.__wbindgen_export_6.get(_.dtor)(s,_.b),j.unregister(_)):_.a=s}};return c.original=_,j.register(c,_,_),c}function E(t){const e=typeof t;if(e=="number"||e=="boolean"||t==null)return`${t}`;if(e=="string")return`"${t}"`;if(e=="symbol"){const _=t.description;return _==null?"Symbol":`Symbol(${_})`}if(e=="function"){const _=t.name;return typeof _=="string"&&_.length>0?`Function(${_})`:"Function"}if(Array.isArray(t)){const _=t.length;let c="[";_>0&&(c+=E(t[0]));for(let i=1;i<_;i++)c+=", "+E(t[i]);return c+="]",c}const n=/\\[object ([^\\]]+)\\]/.exec(toString.call(t));let r;if(n&&n.length>1)r=n[1];else return toString.call(t);if(r=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:r}function m(t){const e=o.__wbindgen_export_2.get(t);return o.__externref_table_dealloc(t),e}function L(t){const e=g(t,o.__wbindgen_malloc,o.__wbindgen_realloc),n=a,r=o.loadSettings(e,n);if(r[1])throw m(r[0])}function v(t,e){o.wasm_bindgen__convert__closures_____invoke__ha5b2289bd84e4451(t,e)}function W(t,e,n){o.closure1451_externref_shim(t,e,n)}function U(t,e,n,r){o.closure2451_externref_shim(t,e,n,r)}const z=["omit","same-origin","include"],q=["same-origin","no-cors","cors","navigate"],O=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>o.__wbg_wasmreader_free(t>>>0,1));class T{static __wrap(e){e=e>>>0;const n=Object.create(T.prototype);return n.__wbg_ptr=e,O.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,O.unregister(this),e}free(){const e=this.__destroy_into_raw();o.__wbg_wasmreader_free(e,0)}static fromBlob(e,n){const r=g(e,o.__wbindgen_malloc,o.__wbindgen_realloc),_=a;return o.wasmreader_fromBlob(r,_,n)}static fromBlobFragment(e,n,r){const _=g(e,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;return o.wasmreader_fromBlobFragment(_,c,n,r)}activeLabel(){const e=o.wasmreader_activeLabel(this.__wbg_ptr);let n;return e[0]!==0&&(n=b(e[0],e[1]).slice(),o.__wbindgen_free(e[0],e[1]*1,1)),n}manifestStore(){const e=o.wasmreader_manifestStore(this.__wbg_ptr);if(e[2])throw m(e[1]);return m(e[0])}activeManifest(){const e=o.wasmreader_activeManifest(this.__wbg_ptr);if(e[2])throw m(e[1]);return m(e[0])}json(){let e,n;try{const r=o.wasmreader_json(this.__wbg_ptr);return e=r[0],n=r[1],b(r[0],r[1])}finally{o.__wbindgen_free(e,n,1)}}resourceToBuffer(e){const n=g(e,o.__wbindgen_malloc,o.__wbindgen_realloc),r=a,_=o.wasmreader_resourceToBuffer(this.__wbg_ptr,n,r);if(_[2])throw m(_[1]);return m(_[0])}}function C(){const t={};return t.wbg={},t.wbg.__wbg_Error_0497d5bdba9362e5=function(e,n){return Error(b(e,n))},t.wbg.__wbg_abort_18ba44d46e13d7fe=function(e){e.abort()},t.wbg.__wbg_abort_4198a1129c47f21a=function(e,n){e.abort(n)},t.wbg.__wbg_append_0342728346e47425=function(){return u(function(e,n,r,_,c){e.append(b(n,r),b(_,c))},arguments)},t.wbg.__wbg_arrayBuffer_d58b858456021d7f=function(){return u(function(e){return e.arrayBuffer()},arguments)},t.wbg.__wbg_buffer_a1a27a0dfa70165d=function(e){return e.buffer},t.wbg.__wbg_buffer_e495ba54cee589cc=function(e){return e.buffer},t.wbg.__wbg_byteLength_937f8a52f9697148=function(e){return e.byteLength},t.wbg.__wbg_call_f2db6205e5c51dc8=function(){return u(function(e,n,r){return e.call(n,r)},arguments)},t.wbg.__wbg_call_fbe8be8bf6436ce5=function(){return u(function(e,n){return e.call(n)},arguments)},t.wbg.__wbg_clearTimeout_0b53d391c1b94dda=function(e){return clearTimeout(e)},t.wbg.__wbg_done_4d01f352bade43b7=function(e){return e.done},t.wbg.__wbg_error_7534b8e9a36f1ab4=function(e,n){let r,_;try{r=e,_=n,console.error(b(e,n))}finally{o.__wbindgen_free(r,_,1)}},t.wbg.__wbg_fetch_11bff8299d0ecd2b=function(e){return fetch(e)},t.wbg.__wbg_fetch_a8e43a4e138dfc93=function(e,n){return e.fetch(n)},t.wbg.__wbg_from_12ff8e47307bd4c7=function(e){return Array.from(e)},t.wbg.__wbg_getTime_2afe67905d873e92=function(e){return e.getTime()},t.wbg.__wbg_get_92470be87867c2e5=function(){return u(function(e,n){return Reflect.get(e,n)},arguments)},t.wbg.__wbg_has_809e438ee9d787a7=function(){return u(function(e,n){return Reflect.has(e,n)},arguments)},t.wbg.__wbg_headers_0f0cbdc6290b6780=function(e){return e.headers},t.wbg.__wbg_instanceof_Response_e80ce8b7a2b968d2=function(e){let n;try{n=e instanceof Response}catch{n=!1}return n},t.wbg.__wbg_iterator_4068add5b2aef7a6=function(){return Symbol.iterator},t.wbg.__wbg_length_ab6d22b5ead75c72=function(e){return e.length},t.wbg.__wbg_new0_97314565408dea38=function(){return new Date},t.wbg.__wbg_new_07b483f72211fd66=function(){return new Object},t.wbg.__wbg_new_186abcfdff244e42=function(){return u(function(){return new AbortController},arguments)},t.wbg.__wbg_new_476169e6d59f23ae=function(e,n){return new Error(b(e,n))},t.wbg.__wbg_new_4796e1cd2eb9ea6d=function(){return u(function(){return new Headers},arguments)},t.wbg.__wbg_new_58353953ad2097cc=function(){return new Array},t.wbg.__wbg_new_58fdb85a58696862=function(){return u(function(){return new FileReaderSync},arguments)},t.wbg.__wbg_new_8a6f238a6ece86ea=function(){return new Error},t.wbg.__wbg_new_a979b4b45bd55c7f=function(){return new Map},t.wbg.__wbg_new_e30c39c06edaabf2=function(e,n){try{var r={a:e,b:n},_=(i,s)=>{const w=r.a;r.a=0;try{return U(w,r.b,i,s)}finally{r.a=w}};return new Promise(_)}finally{r.a=r.b=0}},t.wbg.__wbg_new_e52b3efaaa774f96=function(e){return new Uint8Array(e)},t.wbg.__wbg_newfromslice_7c05ab1297cb2d88=function(e,n){return new Uint8Array(k(e,n))},t.wbg.__wbg_newnoargs_ff528e72d35de39a=function(e,n){return new Function(b(e,n))},t.wbg.__wbg_newwithbyteoffsetandlength_3b01ecda099177e8=function(e,n,r){return new Uint8Array(e,n>>>0,r>>>0)},t.wbg.__wbg_newwithlength_08f872dc1e3ada2e=function(e){return new Uint8Array(e>>>0)},t.wbg.__wbg_newwithstrandinit_f8a9dbe009d6be37=function(){return u(function(e,n,r){return new Request(b(e,n),r)},arguments)},t.wbg.__wbg_next_8bb824d217961b5d=function(e){return e.next},t.wbg.__wbg_next_e2da48d8fff7439a=function(){return u(function(e){return e.next()},arguments)},t.wbg.__wbg_now_eb0821f3bd9f6529=function(){return Date.now()},t.wbg.__wbg_queueMicrotask_46c1df247678729f=function(e){queueMicrotask(e)},t.wbg.__wbg_queueMicrotask_8acf3ccb75ed8d11=function(e){return e.queueMicrotask},t.wbg.__wbg_readAsArrayBuffer_5af53619afa1b299=function(){return u(function(e,n){return e.readAsArrayBuffer(n)},arguments)},t.wbg.__wbg_resolve_0dac8c580ffd4678=function(e){return Promise.resolve(e)},t.wbg.__wbg_setTimeout_73ce8df12de4f2f2=function(e,n){return setTimeout(e,n)},t.wbg.__wbg_set_3f1d0b984ed272ed=function(e,n,r){e[n]=r},t.wbg.__wbg_set_7422acbe992d64ab=function(e,n,r){e[n>>>0]=r},t.wbg.__wbg_set_d6bdfd275fb8a4ce=function(e,n,r){return e.set(n,r)},t.wbg.__wbg_set_fe4e79d1ed3b0e9b=function(e,n,r){e.set(n,r>>>0)},t.wbg.__wbg_setbody_971ec015fc13d6b4=function(e,n){e.body=n},t.wbg.__wbg_setcredentials_920d91fb5984c94a=function(e,n){e.credentials=z[n]},t.wbg.__wbg_setheaders_65a4eb4c0443ae61=function(e,n){e.headers=n},t.wbg.__wbg_setmethod_8ce1be0b4d701b7c=function(e,n,r){e.method=b(n,r)},t.wbg.__wbg_setmode_bd35f026f55b6247=function(e,n){e.mode=q[n]},t.wbg.__wbg_setsignal_8e72abfe7ee03c97=function(e,n){e.signal=n},t.wbg.__wbg_signal_b96223519a041faa=function(e){return e.signal},t.wbg.__wbg_size_e2929e11261f04db=function(e){return e.size},t.wbg.__wbg_slice_efdd8b335ee00bd0=function(){return u(function(e,n,r){return e.slice(n,r)},arguments)},t.wbg.__wbg_stack_0ed75d68575b0f3c=function(e,n){const r=n.stack,_=g(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;d().setInt32(e+4,c,!0),d().setInt32(e+0,_,!0)},t.wbg.__wbg_static_accessor_GLOBAL_487c52c58d65314d=function(){const e=typeof global>"u"?null:global;return x(e)?0:h(e)},t.wbg.__wbg_static_accessor_GLOBAL_THIS_ee9704f328b6b291=function(){const e=typeof globalThis>"u"?null:globalThis;return x(e)?0:h(e)},t.wbg.__wbg_static_accessor_SELF_78c9e3071b912620=function(){const e=typeof self>"u"?null:self;return x(e)?0:h(e)},t.wbg.__wbg_static_accessor_WINDOW_a093d21393777366=function(){const e=typeof window>"u"?null:window;return x(e)?0:h(e)},t.wbg.__wbg_status_a54682bbe52f9058=function(e){return e.status},t.wbg.__wbg_stringify_c242842b97f054cc=function(){return u(function(e){return JSON.stringify(e)},arguments)},t.wbg.__wbg_then_82ab9fb4080f1707=function(e,n,r){return e.then(n,r)},t.wbg.__wbg_then_db882932c0c714c6=function(e,n){return e.then(n)},t.wbg.__wbg_url_e6ed869ea05b7a71=function(e,n){const r=n.url,_=g(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;d().setInt32(e+4,c,!0),d().setInt32(e+0,_,!0)},t.wbg.__wbg_value_17b896954e14f896=function(e){return e.value},t.wbg.__wbg_wasmreader_new=function(e){return T.__wrap(e)},t.wbg.__wbindgen_as_number=function(e){return+e},t.wbg.__wbindgen_bigint_from_i64=function(e){return e},t.wbg.__wbindgen_bigint_from_u64=function(e){return BigInt.asUintN(64,e)},t.wbg.__wbindgen_cb_drop=function(e){const n=e.original;return n.cnt--==1?(n.a=0,!0):!1},t.wbg.__wbindgen_closure_wrapper10869=function(e,n,r){return B(e,n,1447,v)},t.wbg.__wbindgen_closure_wrapper10883=function(e,n,r){return B(e,n,1450,W)},t.wbg.__wbindgen_debug_string=function(e,n){const r=E(n),_=g(r,o.__wbindgen_malloc,o.__wbindgen_realloc),c=a;d().setInt32(e+4,c,!0),d().setInt32(e+0,_,!0)},t.wbg.__wbindgen_init_externref_table=function(){const e=o.__wbindgen_export_2,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,!0),e.set(n+3,!1)},t.wbg.__wbindgen_is_function=function(e){return typeof e=="function"},t.wbg.__wbindgen_is_object=function(e){const n=e;return typeof n=="object"&&n!==null},t.wbg.__wbindgen_is_string=function(e){return typeof e=="string"},t.wbg.__wbindgen_is_undefined=function(e){return e===void 0},t.wbg.__wbindgen_memory=function(){return o.memory},t.wbg.__wbindgen_number_new=function(e){return e},t.wbg.__wbindgen_string_get=function(e,n){const r=n,_=typeof r=="string"?r:void 0;var c=x(_)?0:g(_,o.__wbindgen_malloc,o.__wbindgen_realloc),i=a;d().setInt32(e+4,i,!0),d().setInt32(e+0,c,!0)},t.wbg.__wbindgen_string_new=function(e,n){return b(e,n)},t.wbg.__wbindgen_throw=function(e,n){throw new Error(b(e,n))},t}function N(t,e){return o=t.exports,l=null,y=null,o.__wbindgen_start(),o}function $(t){if(o!==void 0)return o;typeof t<"u"&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=C();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));const n=new WebAssembly.Instance(t,e);return N(n)}function F(t,e){const n={type:"success",...t!==void 0?{payload:t}:{}};postMessage(n,e??[])}function V(t){postMessage({type:"error",error:t})}function P(t){onmessage=async e=>{try{const{args:n,method:r}=e.data,_=await t[r](...n);(_==null?void 0:_.data)!==void 0?F(_.data,_.transfer):F()}catch(n){V(n)}}}function G(){let t=0;const e=new Map;return{add(n){const r=t++;return e.set(r,n),r},get(n){const r=e.get(n);if(!r)throw new Error("Attempted to use an object that has been freed");return r},remove(n){return e.delete(n)}}}const f=G();P({async initWorker(t,e){$(t),e&&L(e)},async reader_fromBlob(t,e){const n=await T.fromBlob(t,e);return{data:f.add(n)}},async reader_fromBlobFragment(t,e,n){const r=await T.fromBlobFragment(t,e,n);return{data:f.add(r)}},reader_activeLabel(t){return{data:f.get(t).activeLabel()??null}},reader_manifestStore(t){return{data:f.get(t).manifestStore()}},reader_activeManifest(t){return{data:f.get(t).activeManifest()}},reader_json(t){return{data:f.get(t).json()}},reader_resourceToBuffer(t,e){const r=f.get(t).resourceToBuffer(e);return{data:r,transfer:[r]}},reader_free(t){f.get(t).free(),f.remove(t)}})})();\n', f = typeof self < "u" && self.Blob && new Blob([l], { type: "text/javascript;charset=utf-8" });
2
2
  function v(e) {
3
3
  let t;
4
4
  try {
@@ -20,7 +20,7 @@ function v(e) {
20
20
  t && (self.URL || self.webkitURL).revokeObjectURL(t);
21
21
  }
22
22
  }
23
- function S(e, t) {
23
+ function T(e, t) {
24
24
  e.onmessage = (n) => {
25
25
  const { data: r } = n;
26
26
  r.type === "success" ? t.onSuccess(r == null ? void 0 : r.payload) : t.onError(r == null ? void 0 : r.error);
@@ -30,33 +30,33 @@ function S(e, t) {
30
30
  t.onError(n.data);
31
31
  };
32
32
  }
33
- async function T(e) {
34
- const { wasm: t, settingsString: n } = e, r = new v(), o = (_) => new Promise((a, c) => {
35
- S(r, {
36
- onSuccess: (i) => a(i),
37
- onError: (i) => c(i)
33
+ async function S(e) {
34
+ const { wasm: t, settingsString: n } = e, r = new v(), o = (_) => new Promise((a, i) => {
35
+ T(r, {
36
+ onSuccess: (c) => a(c),
37
+ onError: (c) => i(c)
38
38
  });
39
- const { method: y, args: h, transfer: x } = _;
40
- r.postMessage({ method: y, args: h }, x ?? []);
39
+ const { method: p, args: h, transfer: x } = _;
40
+ r.postMessage({ method: p, args: h }, x ?? []);
41
41
  });
42
42
  return await o({ method: "initWorker", args: [t, n] }), {
43
43
  execute: o,
44
44
  terminate: () => r.terminate()
45
45
  };
46
46
  }
47
- class g extends Error {
47
+ class b extends Error {
48
48
  constructor(t) {
49
49
  super(
50
- `The provided asset was too large. Size: ${t} bytes. Maximum: ${u}.`
50
+ `The provided asset was too large. Size: ${t} bytes. Maximum: ${s}.`
51
51
  ), this.name = "AssetTooLargeError";
52
52
  }
53
53
  }
54
- class b extends Error {
54
+ class g extends Error {
55
55
  constructor(t) {
56
56
  super(`Unsupported format: ${t}.`), this.name = "UnsupportedFormatError";
57
57
  }
58
58
  }
59
- const R = [
59
+ const E = [
60
60
  "jpg",
61
61
  "video/mp4",
62
62
  "image/heif",
@@ -116,9 +116,9 @@ const R = [
116
116
  "heif"
117
117
  ];
118
118
  function w(e) {
119
- return R.includes(e);
119
+ return E.includes(e);
120
120
  }
121
- const u = 10 ** 9;
121
+ const s = 10 ** 9;
122
122
  function j(e) {
123
123
  const t = new FinalizationRegistry((n) => {
124
124
  e.execute({ method: "reader_free", args: [n] });
@@ -126,9 +126,9 @@ function j(e) {
126
126
  return {
127
127
  async fromBlob(n, r) {
128
128
  if (!w(n))
129
- throw new b(n);
130
- if (r.size > u)
131
- throw new g(r.size);
129
+ throw new g(n);
130
+ if (r.size > s)
131
+ throw new b(r.size);
132
132
  const o = await e.execute({
133
133
  method: "reader_fromBlob",
134
134
  args: [n, r]
@@ -139,16 +139,16 @@ function j(e) {
139
139
  },
140
140
  async fromBlobFragment(n, r, o) {
141
141
  if (!w(n))
142
- throw new b(n);
143
- if (r.size > u)
144
- throw new g(r.size);
142
+ throw new g(n);
143
+ if (r.size > s)
144
+ throw new b(r.size);
145
145
  const _ = await e.execute({
146
146
  method: "reader_fromBlobFragment",
147
147
  args: [n, r, o]
148
- }), a = Symbol(_), c = d(e, _, () => {
148
+ }), a = Symbol(_), i = d(e, _, () => {
149
149
  t.unregister(a);
150
150
  });
151
- return t.register(c, _, a), c;
151
+ return t.register(i, _, a), i;
152
152
  }
153
153
  };
154
154
  }
@@ -187,45 +187,44 @@ function d(e, t, n) {
187
187
  }
188
188
  };
189
189
  }
190
- let m;
191
- const E = typeof TextDecoder < "u" ? new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 }) : { decode: () => {
190
+ let m, R = typeof TextDecoder < "u" ? new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 }) : { decode: () => {
192
191
  throw Error("TextDecoder not available");
193
192
  } };
194
- typeof TextDecoder < "u" && E.decode();
195
- const s = typeof TextEncoder < "u" ? new TextEncoder("utf-8") : { encode: () => {
193
+ typeof TextDecoder < "u" && R.decode();
194
+ const u = typeof TextEncoder < "u" ? new TextEncoder("utf-8") : { encode: () => {
196
195
  throw Error("TextEncoder not available");
197
196
  } };
198
- s.encodeInto;
197
+ u.encodeInto;
199
198
  typeof FinalizationRegistry > "u" || new FinalizationRegistry((e) => {
200
199
  m.__wbindgen_export_6.get(e.dtor)(e.a, e.b);
201
200
  });
202
201
  typeof FinalizationRegistry > "u" || new FinalizationRegistry((e) => m.__wbg_wasmreader_free(e >>> 0, 1));
203
- const B = "sha512-2Xw4vi1zAuw6ShG+SsG+eJO/jyxat4s8pPK+OcnW963sRFiQXxjHzNcDdbpcNVYrbOO2qgk5FF0osaiBCVi7Ow==";
204
- function A(e) {
205
- return JSON.stringify(p(e));
202
+ const A = "sha512-7w/e+kyxISej6Gt6cK/d939I2c82jl9nnydzcwjzuGtJbfA4Vvx3HQUf7dmmapRzvFXZxg5NrSU8tz4v7hBrhw==";
203
+ function B(e) {
204
+ return JSON.stringify(y(e));
206
205
  }
207
- function p(e) {
206
+ function y(e) {
208
207
  return Object.entries(e).reduce(
209
- (n, [r, o]) => (n[O(r)] = typeof o == "object" ? p(o) : o, n),
208
+ (n, [r, o]) => (n[M(r)] = typeof o == "object" ? y(o) : o, n),
210
209
  {}
211
210
  );
212
211
  }
213
- function O(e) {
212
+ function M(e) {
214
213
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
215
214
  }
216
215
  async function F(e) {
217
- const { wasmSrc: t, settings: n } = e, r = typeof t == "string" ? await M(t) : t, o = n ? A(n) : void 0, _ = await T({ wasm: r, settingsString: o });
216
+ const { wasmSrc: t, settings: n } = e, r = typeof t == "string" ? await L(t) : t, o = n ? B(n) : void 0, _ = await S({ wasm: r, settingsString: o });
218
217
  return {
219
218
  reader: j(_),
220
219
  dispose: _.terminate
221
220
  };
222
221
  }
223
- async function M(e) {
224
- const t = await fetch(e, { integrity: B });
222
+ async function L(e) {
223
+ const t = await fetch(e, { integrity: A });
225
224
  return await WebAssembly.compileStreaming(t);
226
225
  }
227
226
  export {
228
- R as READER_SUPPORTED_FORMATS,
227
+ E as READER_SUPPORTED_FORMATS,
229
228
  F as createC2pa,
230
229
  w as isSupportedReaderFormat
231
230
  };
@@ -10,8 +10,14 @@ export interface Config {
10
10
  */
11
11
  settings?: Settings;
12
12
  }
13
- interface C2paSdk {
13
+ export interface C2paSdk {
14
+ /**
15
+ * Contains methods for creating Reader objects.
16
+ */
14
17
  reader: ReaderFactory;
18
+ /**
19
+ * Terminates the SDK's underlying web worker.
20
+ */
15
21
  dispose: () => void;
16
22
  }
17
23
  /**
@@ -28,5 +34,4 @@ interface C2paSdk {
28
34
  * ```
29
35
  */
30
36
  export declare function createC2pa(config: Config): Promise<C2paSdk>;
31
- export {};
32
37
  //# sourceMappingURL=c2pa.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"c2pa.d.ts","sourceRoot":"","sources":["../../src/lib/c2pa.ts"],"names":[],"mappings":"AASA,OAAO,EAAuB,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAsB,MAAM,eAAe,CAAC;AAE7D,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,UAAU,OAAO;IACf,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAcjE"}
1
+ {"version":3,"file":"c2pa.d.ts","sourceRoot":"","sources":["../../src/lib/c2pa.ts"],"names":[],"mappings":"AASA,OAAO,EAAuB,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAsB,MAAM,eAAe,CAAC;AAE7D,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;IAEtB;;OAEG;IACH,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAcjE"}
@@ -1,6 +1,9 @@
1
1
  import { Manifest, ManifestStore } from '@contentauth/c2pa-types';
2
2
  import { WorkerManager } from './worker/workerManager.js';
3
3
  export declare const MAX_SIZE_IN_BYTES: number;
4
+ /**
5
+ * A collection of functions that permit the creation of Reader objects from various sources.
6
+ */
4
7
  export interface ReaderFactory {
5
8
  /**
6
9
  * Create a Reader from an asset's format and a blob of its bytes.
@@ -12,6 +15,16 @@ export interface ReaderFactory {
12
15
  fromBlob: (format: string, blob: Blob) => Promise<Reader>;
13
16
  fromBlobFragment: (format: string, init: Blob, fragment: Blob) => Promise<Reader>;
14
17
  }
18
+ /**
19
+ * Exposes methods for reading C2PA data out of an asset.
20
+ *
21
+ * @example Getting an asset's active manifest:
22
+ * ```
23
+ * const reader = await c2pa.reader.fromBlob(blob.type, blob);
24
+ *
25
+ * const activeManifest = await reader.activeManfiest();
26
+ * ```
27
+ */
15
28
  export interface Reader {
16
29
  /**
17
30
  * @returns The label of the active manifest.
@@ -38,6 +51,15 @@ export interface Reader {
38
51
  *
39
52
  * @param uri URI of the binary object to resolve.
40
53
  * @returns An array buffer of the resource's bytes.
54
+ *
55
+ * @example Retrieving a thumbnail from the resource store:
56
+ * ```
57
+ * const reader = await c2pa.reader.fromBlob(blob.type, blob);
58
+ *
59
+ * const activeManifest = await reader.activeManifest();
60
+ *
61
+ * const thumbnailBuffer = await reader.resourceToBuffer(activeManifest.thumbnail!.identifier);
62
+ * ```
41
63
  */
42
64
  resourceToBuffer: (uri: string) => Promise<ArrayBuffer>;
43
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/lib/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,eAAO,MAAM,iBAAiB,QAAU,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1D,gBAAgB,EAAE,CAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,IAAI,KACX,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE1C;;;;OAIG;IACH,aAAa,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IAE5C;;;;OAIG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IAExC;;OAEG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IAEzB;;;;;OAKG;IACH,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAExD;;OAEG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAoDxE"}
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/lib/reader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG/D,eAAO,MAAM,iBAAiB,QAAU,CAAC;AAEzC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1D,gBAAgB,EAAE,CAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,IAAI,KACX,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE1C;;;;OAIG;IACH,aAAa,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IAE5C;;;;OAIG;IACH,cAAc,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IAExC;;OAEG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IAEzB;;;;;;;;;;;;;;OAcG;IACH,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAExD;;OAEG;IACH,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAoDxE"}
@@ -6,23 +6,46 @@
6
6
  * accordance with the terms of the Adobe license agreement accompanying
7
7
  * it.
8
8
  */
9
+ /**
10
+ * Settings used to configure the SDK's behavior.
11
+ */
9
12
  export interface Settings {
13
+ /**
14
+ * Trust configuration for C2PA claim validation.
15
+ */
10
16
  trust?: TrustSettings;
17
+ /**
18
+ * Trust configuration for CAWG identity valdation.
19
+ */
11
20
  cawgTrust?: TrustSettings;
12
21
  verify?: VerifySettings;
13
22
  }
14
- interface TrustSettings {
23
+ export interface TrustSettings {
24
+ /**
25
+ * "User" trust anchors. Any asset validated off of this trust list will will have a "signingCredential.trusted" result with an explanation noting the trust source is a "User" anchor.
26
+ */
15
27
  userAnchors?: string;
28
+ /**
29
+ * "System" trust anchors. Any asset validated off of this trust list will will have a "signingCredential.trusted" result with an explanation noting the trust source is a "System" anchor.
30
+ */
16
31
  trustAnchors?: string;
32
+ /**
33
+ * Trust store
34
+ */
17
35
  trustConfig?: string;
36
+ /**
37
+ * End-entity certificates.
38
+ */
18
39
  allowedList?: string;
19
40
  }
20
- interface VerifySettings {
41
+ export interface VerifySettings {
42
+ /**
43
+ * Enable trust list validation.
44
+ */
21
45
  verifyTrust?: boolean;
22
46
  }
23
47
  /**
24
48
  * Converts a settings object to a JSON string of the structure expected by c2pa-rs.
25
49
  */
26
50
  export declare function settingsToWasmJson(settings: Settings): string;
27
- export {};
28
51
  //# sourceMappingURL=settings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/lib/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,UAAU,aAAa;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,cAAc;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,UAEpD"}
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/lib/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,UAEpD"}
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentauth/c2pa-web",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -18,14 +18,17 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@contentauth/c2pa-wasm": "0.2.0",
22
- "@contentauth/c2pa-types": "0.2.0"
21
+ "@contentauth/c2pa-types": "0.2.1",
22
+ "@contentauth/c2pa-wasm": "0.2.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@playwright/test": "^1.55.0",
26
26
  "@types/ssri": "^7.1.5",
27
27
  "@vitest/browser": "^3.2.4",
28
+ "typedoc": "^0.28.12",
28
29
  "rimraf": "^6.0.1"
29
30
  },
30
- "scripts": {}
31
+ "scripts": {
32
+ "build:docs": "typedoc src/index.ts"
33
+ }
31
34
  }